/**
 * @author guysagy
 */

package utilities;

import javax.servlet.http.*;

public class CookiesMgr
{
    public static String getCookieValue(HttpServletRequest request, String cookieName) throws NullPointerException
    {
        if (request == null || cookieName == null)
            throw new NullPointerException();

        String cookieValue = null;
        Cookie[] cookiesArray = request.getCookies();
        if (cookiesArray != null)
        {
            for (int i = 0; i < cookiesArray.length; ++i)
            {
                if (cookieName.equals(cookiesArray[i].getName()))
                {
                    cookieValue = cookiesArray[i].getValue();
                    break;
                }
            }
        }

        return cookieValue;
    }
}
